<template>
	<view style="min-height: 100vh;">
		<view class="header">
			<x-status-bar></x-status-bar>
			<view class="flex-center-between header-navbar">
				<x-back-btn></x-back-btn>
				<view class="u-f-40 font-bold common-title">{{ lang_message.logisticsNotice }}</view>
			</view>
		</view>

		<!-- 列表 -->
		<mescroll-body height="calc(100vh - 98rpx - var(--status-bar-height))" ref="mescrollRef"
			@init="mescrollInit" @down="downCallback" @up="upCallback">
			<view style="padding: 20rpx 30rpx 0;">
				<view v-for="(item, index) in dataList" :key="index" class="card-box u-m-b-20">
					<view class="flex-center-between">
						<view class="u-f-28 u-lh-40">{{ item.title || '' }}</view>
						<view class="u-f-24 u-lh-34 color-grew">{{ dayjs(item.createTime || dayjs()).format('YYYY-MM-DD HH:mm') }}</view>
					</view>

					<view class="u-m-t-18 flex-center" style="width: 100%;">
						<view class="card-image clear-flex">
							<x-image :src="showImage(item.imgUrl, 'logo')"/>
						</view>
						<view class="u-m-l-18">
							<view class="u-f-32 u-lh-44 font-medio">
								{{ item.content || '' }}
							</view>
							<view class="u-m-t-10 u-f-28 u-lh-40 color-grew">
								{{ lang_message.orderNumber }}：{{ item.orderNumber || '' }}
							</view>
						</view>
					</view>
				</view>

				<!-- 留空 -->
				<view style="height: 200rpx;"></view>
			</view>
		</mescroll-body>
	</view>
</template>

<script>
	import {
		notifyPage
	} from '@/api/base.js'
	import MescrollMixin from "@/components/mescroll-uni/mescroll-mixins.js";

	export default {
		mixins: [MescrollMixin], // 使用mixin
		data() {
			let types = [{
					label: '订单已发货通知',
					labelKey: 'orderSendNotice',
					tips: '您的商品已发货，请留意快递信息'
				},
				{
					label: '订单成功签收通知',
					labelKey: 'orderSignNotice',
					tips: '您的商品已成功签收'
				},
				{
					label: '拼团成功通知',
					labelKey: 'collageSuccessNotice',
					tips: '您的商品拼团成功，请留意快递信息'
				},
				{
					label: '拼团失败通知',
					labelKey: 'collageFailureNotice',
					tips: '您的商品拼团未成功，可进行退款'
				},
				{
					label: '退款成功通知',
					labelKey: 'reefundSuccessNotice',
					tips: '预售未达到指定人数，货款已原路退回'
				},
				{
					label: '参与预售成功通知',
					labelKey: 'preSaleSuccessNotice',
					tips: '预售人数已达标，将尽快为您安排发货'
				}
			]
			return {
				types,

				dataList: [{
					type: 1
				}, {
					type: 4
				}, {
					type: 5
				}, {
					type: 3
				}]
			}
		},
		onLoad() {

		},
		methods: {
			dealType(type) {
				return this.types[type - 1]
			},
			/*上拉加载的回调: 其中page.num:当前页 从1开始, page.size:每页数据条数,默认10 */
			upCallback(page) {
				let node = this.$refs['mescrollRef']
				notifyPage({
					pageNumber: page.num,
					pageSize: page.size,
					type: 2
				}).then(res => {
					node && node.mescroll.endSuccess(res.list.length);
					if (page.num == 1) this.dataList = []; //如果是第一页需手动制空列表
					this.dataList = this.dataList.concat(res.list); //追加新数据
				}).catch(() => {
					node && node.mescroll.endErr();
				})
			},
			downCallback() {
				let node = this.$refs['mescrollRef']
				node && node.mescroll.resetUpScroll()
			},
		}
	}
</script>

<style lang="scss" scoped>
	.card {
		&-box {
			padding: 20rpx;
			background-color: #F9F9F9;
			border-radius: 14rpx;
		}

		&-image {
			width: 98rpx;
			height: 98rpx;
			border-radius: 12rpx;
			overflow: hidden;
			background-color: #f9f9f9;
		}
	}
</style>
